from selenium.webdriver.common.by import By

class PageEcshopFrontSearchGoods():
    def __init__(self,driver):
        self.driver = driver #控制浏览器

    #定义定位器
        self.loc_ele_find_input_goods = (By.NAME,"keywords")
        self.loc_ele_find_click_search = (By.NAME,'imageField')
        self.loc_ele_find_click_goods = (By.XPATH, '//form[@id="compareForm"]/div/div[3]/a/img')

    def ele_find_input_goods(self,goods): #搜索框输入商品
        self.driver.find_element(*self.loc_ele_find_input_goods).send_keys(goods)

    def ele_find_click_search(self):#点击搜索按钮
        self.driver.find_element(*self.loc_ele_find_click_search).click()
    def ele_find_click_goods(self):#点击商品，查看详情
        self.driver.find_element(*self.loc_ele_find_click_goods).click()

    def search(self,goods):
        self.ele_find_input_goods(goods)
        self.ele_find_click_search()
        self.ele_find_click_goods()






